package com.example.springboot.Service;

import com.example.springboot.Mapper.UserMapping;
import com.example.springboot.pojo.Users;
import org.hibernate.validator.constraints.ru.INN;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Service
public class UserService {
    @Autowired
    private UserMapping userMapping;

    // 获取用户列表
    @Transactional
    public List<Users> getList(){
        return userMapping.getList();
    }

    // 注册
    @Transactional
    public Integer register(String user_id, String user_name, String password, String address, String tel, Object deleted_at,  Object updated_at, Date created_at, int role){
        return userMapping.register(user_id, user_name, password, address, tel, deleted_at,  updated_at, created_at, role);
    }

    // 登录
    @Transactional
    public Users login(String username, String password){
        return userMapping.login(username, password);
    }

    // 修改密码
    @Transactional
    public Integer updatePassword (String password, Date updated_at, String id){
        return userMapping.updatePassword(password, updated_at, id);
    }

    // 修改权限
    @Transactional
    public Integer updateRole(int role, Date updated_at, String id){
        return userMapping.updateRole(role, updated_at, id);
    }

    // 获取用户信息
    @Transactional
    public Users getUserInfo(String id){
        return userMapping.getUserInfo(id);
    }
}
